#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include "stu_mis.h"

int start_menu()
{
    printf("\n\n");
    printf("\t┏━━━━━━━━━━━━━━━━━━━━━━━━━┓\n");
    printf("\t┃           欢迎使用学生管理系统BetaV1.3           ┃\n");
    printf("\t┃                               by hht      ┃\n");
    printf("\t┃  1、查看所有学生信息                             ┃\n");
    printf("\t┃  2、添加学生信息                                     ┃\n");
    printf("\t┃  3、查找学生                                     ┃\n");
    printf("\t┃  4、修改学生信息                           ┃\n");
    printf("\t┃  5、删除学生信息                           ┃\n");
    printf("\t┃  0、退出                                         ┃\n");
    printf("\t┃                                                  ┃\n");
    printf("\t┗━━━━━━━━━━━━━━━━━━━━━━━━━┛\n\n");

    int kbscan;
    while(1)
    {
        if(1 == scanf("%d", &kbscan))
        {
            if(kbscan < 0 || kbscan > 5)
            {
                printf("\t┏━━━━━━━━━━━━━━━━━━━━━━━━━┓\n");
                printf("\t┃           欢迎使用学生管理系统BetaV1.3           ┃\n");
                printf("\t┃                               by hht      ┃\n");
                printf("\t┃  请输入正确的选项！                             ┃\n");
                printf("\t┃                                                  ┃\n");
                printf("\t┗━━━━━━━━━━━━━━━━━━━━━━━━━┛\n\n");
                continue;
            }
            else
                break;
        }
    }
    return kbscan;
}

int find_menu()
{
    printf("\n\n");
    printf("\t┏━━━━━━━━━━━━━━━━━━━━━━━━━┓\n");
    printf("\t┃           欢迎使用学生管理系统BetaV1.3           ┃\n");
    printf("\t┃                               by hht                    ┃\n");
    printf("\t┃  1、按学号进行查找                                      ┃\n");
    printf("\t┃  2、按姓名进行查找                                     ┃\n");
    printf("\t┃  3、按性别进行查找                                     ┃\n");
    printf("\t┃  4、按成绩进行查找                                  ┃\n");
    printf("\t┃  5、返回主界面                                         ┃\n");
    printf("\t┃  0、退出                                         ┃\n");
    printf("\t┃                                                  ┃\n");
    printf("\t┗━━━━━━━━━━━━━━━━━━━━━━━━━┛\n\n");

    int kbscan;
    while (1)
    {
        if (1 == scanf("%d", &kbscan))
        {
            if (kbscan < 0 || kbscan > 5)
            {
                printf("\t┏━━━━━━━━━━━━━━━━━━━━━━━━━┓\n");
                printf("\t┃           欢迎使用学生管理系统BetaV1.3           ┃\n");
                printf("\t┃                               by hht      ┃\n");
                printf("\t┃  请输入正确的选项！                             ┃\n");
                printf("\t┃                                                  ┃\n");
                printf("\t┗━━━━━━━━━━━━━━━━━━━━━━━━━┛\n\n");
                continue;
            }
            else
                break;
        }
    }
    return kbscan;
}

int yor()
{
    int kbscan;
    while (1)
    {
        printf("\n\n");
        printf("\t┏━━━━━━━━━━━━━━━━━━━━━━━━━┓\n");
        printf("\t┃           欢迎使用学生管理系统BetaV1.3           ┃\n");
        printf("\t┃                               by hht                    ┃\n");
        printf("\t┃  1、继续                                      ┃\n");
        printf("\t┃  5、返回主界面                                         ┃\n");
        printf("\t┃  0、退出                                         ┃\n");
        printf("\t┃                                                  ┃\n");
        printf("\t┗━━━━━━━━━━━━━━━━━━━━━━━━━┛\n\n");

        if (1 == scanf("%d", &kbscan))
        {
            if (kbscan != 0 && kbscan != 5 && kbscan != 1)
            {
                printf("\t┏━━━━━━━━━━━━━━━━━━━━━━━━━┓\n");
                printf("\t┃           欢迎使用学生管理系统BetaV1.3           ┃\n");
                printf("\t┃                               by hht      ┃\n");
                printf("\t┃  请输入正确的选项！                             ┃\n");
                printf("\t┃                                                  ┃\n");
                printf("\t┗━━━━━━━━━━━━━━━━━━━━━━━━━┛\n\n");
                continue;
            }
            else
                break;
        }
    }

    return kbscan;
}
